export default {
	data() {
		return {
			baseUrl: this.$baseUrl,
			value: 0,
			id: '',
			cat_id: '',
			data: {
				desc: '', // 默认值为空字符串
				thumb: [],
				name: '',
				price: '',
				sale_num: 0,
			},
			comment: {
				count: 0,
				data: [], // 默认值为空数组
			},
			time: '',
			date: '',
			month: [], // 月份数据
			yearArr: [], // 年份数据
			service_data: '', // service_data
		}
	},
	onLoad(options) {
		this.id = options.id;
		this.cat_id = options.cat_id;
		this.$request.get(`service_read/${this.id}`).then(res => {
			this.data = res.data.data;
		});
		this.dateArr = this.$getDateRanges().currentMonthDates; //赋值当前月份剩余日期
		this.yearArr[0] = this.$getCurrentAndNextMonthYear().currentMonthYear;
		this.yearArr[1] = this.$getCurrentAndNextMonthYear().nextMonthYear;
		this.month = this.$getFormattedMonths();
		this.monthValue = this.month[0].text;
		this.service_data = this.yearArr[0] + '-' + this.dateArr[0].toString().padStart(2, '0');
		this.$request.get(`evaluate_list?service_id=${this.id}`).then(res => {
			this.comment = {
				count: res.data.count || 0,
				data: res.data.data || [], // 确保 data 有默认值
			};
		});
	},
	methods: {
		handleTimeSelected(time) {
			console.log('选择的时间:', time);
			this.time = time;
		},
		handleDateSelected(date, service_data) {
			console.log('选择的日期:', date);
			console.log('service_data:', service_data);
			this.date = date;
			this.service_data = service_data; // 保存 service_data
			this.time = '';
		},
		handleMonthChanged(monthIndex) {
			console.log('选择的月份:', monthIndex);
		},
	}
	// 其他需要复用的方法
};